package 个人密码库;

import 个人密码库.view.UserView;

import java.security.GeneralSecurityException;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Application {
    public static void main(String[] args) {
        Application app = new Application();
        Scanner scanner = new Scanner(System.in);
        UserView view = new UserView(scanner, app.setDefaultConfig());

        try {
            view.operate();
        } catch (SQLException e) {
            throw new RuntimeException("数据库操作异常", e);
        } catch (GeneralSecurityException e) {
            throw new RuntimeException("加密或解密失败", e);
        }
    }

    // 默认配置
    public Map<String, String> setDefaultConfig() {
        Map<String, String> configs = new HashMap<>();

        // 配置数据库
        configs.put("JDBC_URL", "jdbc:mysql://localhost:3306/my_passwords?characterEncoding=utf8");
        configs.put("JDBC_USER", "root");
        configs.put("JDBC_PASSWORD", "");

        // 设置Excel结果文件的输出路径
        configs.put("OUTPUT_PATH", "src/main/java/个人密码库/resources/result/");

        // 设置Excel结果文件的输入路径
        configs.put("INPUT_PATH", "src/main/java/个人密码库/resources/input/");

        return configs;
    }
}
